feat: save input text draft into local storage#9809
feat: save input text draft into local storage#9809uinstinct wants to merge 8 commits intocontinuedev:mainfrom
Conversation
RomneyDa
left a comment
There was a problem hiding this comment.
@uinstinct it looks like this only works for the main input. I think it's an improvement but can we think of a simple way to have this work across conversations and in any tip tap editor when going to settings and back?
- On closing/reopening vs code it's okay to lose drafts in any editor but would be nice if main editor was saved (already works on this branch) and great if all were saved (in a way that doesn't leak local storage etc memory)
- On going to settings and back any editor's content is preserved, as well as the scroll position of the chat history in case I was editing message number 2 in a 5 message sequence
If too many tradeoffs we can merge this but let's brainstorm on full solution first. There might be a simple solution where we don't unmount the component at all when switching to settings (router level fix).
and scroll to position when going back
It currently saves all - there would not be any memory leakage, as far as I think, because there can only be 2 drafts be saved: inputDraft_chat or inputDraft_edit which get cleared during submission
I did a simple implementation for this to save the editing draft and scroll back to chat history position. feat.mp4 |
RomneyDa
left a comment
There was a problem hiding this comment.
@uinstinct I think with the positioned draft approach if the draft is not submitted and a main input message is submitted instead it will not clear the other draft so the UI will glitch around, including if you started up vs code it would "glitch" to the input draft even if it was outdated
| } | ||
| } else { | ||
| if (hasValidEditorContent(content)) { | ||
| const scrollContainer = document.querySelector( |
There was a problem hiding this comment.
let's use a more robust way to get the scroll container e.g. id or non generic class
Added removing of both drafts (editing and main input) after submission and gui window unmount. |
There was a problem hiding this comment.
1 issue found across 1 file (changes from recent commits).
Prompt for AI agents (all issues)
Check if these issues are valid — if so, understand the root cause of each and fix them.
<file name="gui/src/hooks/ParallelListeners.tsx">
<violation number="1" location="gui/src/hooks/ParallelListeners.tsx:270">
P2: The cleanup-only useEffect has no dependency array, so it runs after every render and clears draft keys on each re-render. Because this component re-renders from Redux state updates, saved drafts are repeatedly deleted, undermining persistence. Add a dependency array (or otherwise scope cleanup) so it only runs on unmount if that’s the intent.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
Co-authored-by: cubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com>
There was a problem hiding this comment.
1 issue found across 1 file (changes from recent commits).
Prompt for AI agents (all issues)
Check if these issues are valid — if so, understand the root cause of each and fix them.
<file name="gui/src/hooks/ParallelListeners.tsx">
<violation number="1" location="gui/src/hooks/ParallelListeners.tsx:275">
P2: Cleaning localStorage drafts on ParallelListeners unmount undermines draft persistence and can wipe drafts in Strict Mode remounts or when the root component is disposed.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
Description
Save the unsubmitted input text into local storage so that it persists between reloads and page changes.
resolves CON-5281
AI Code Review
@continue-reviewChecklist
Screen recording or screenshot
before.mp4
after.mp4
Tests
[ What tests were added or updated to ensure the changes work as expected? ]
Continue Tasks:▶️ 2 queued — View all
Summary by cubic
Persist main input drafts across reloads and navigation. Save per-message edit drafts with scroll and focus restore within a session; they clear on app unmount (CON-5281).
New Features
Refactors
Written for commit dde7a97. Summary will update on new commits.